let {
    baseUrl
} = require("./http")
export const urlImg = ''
export const httPrequest = {
    requestData(url) {
        let promise = new Promise(function (resolve, reject) {
            wx.request({
                url: baseUrl + url.url,
                timeout: "10000",
                method: url.method,  //请求方式
                header: {
                    'context-type': 'application/json',
                    "Authorization": wx.getStorageSync('access_token') ?? '', //登录token
                }, // 设置请求的 header
                data: url.data,
                success: function (res) {
                    var status = res.data.resultCode
                    //抛出数据
                    resolve(res.data);
                }
            })
        });
        return promise
    }
}


//上传图片
export const requestupload = (params) => {
    return new Promise((resolve, reject) => {
        wx.uploadFile({
            ...params,
            url: baseUrl + params.url,
            header: {
              "Authorization": wx.getStorageSync('access_token') ?? '', //登录token
          }, // 设置请求的 header
            success: (result) => {
                resolve(result);
            },
            fail: (err) => {
                reject(err)
            }
        })
    })
}


